#!/usr/bin/env python3

import os
import sys

old_info = sys.argv[1]
new_info = sys.argv[2]
filename = sys.argv[3]

filename = "info"
tmp = []

# 读取文件内容
f = open(filename,'r')
for i in f:
    i = i.replace(old_info,new_info).strip()
    tmp.append([i])
f.close()

# 生成修改后的新文件
f = open("info_old",'w')
for i in tmp:
    f.write(str(i[0])+'\n')
f.close()

os.remove(filename) # 移出旧文件
os.rename("info_old",filename)  # 重命名新文件



